package tech.aistar.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
import tech.aistar.entity.House;
import tech.aistar.mapper.EvaluateMapper;
import tech.aistar.mapper.HouseMapper;
import tech.aistar.service.IHouseService;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Auther: shuaiguo
 * @Date: 2020/10/01/17:42
 * @Description:
 */
@Service
public class HouseImpl implements IHouseService {
    @Autowired
    private HouseMapper houseMapper;
    @Override
    public List<House> selectAll() {
        return houseMapper.selectAll();
    }

    @Override
    public void insert(House house) {
houseMapper.insert(house);
    }

    @Override
    public Integer selectHouseId(Integer agentId, Integer landlordId, String houseEvaluate, String landlordRequire, String propertyOwnershipCertificate, String houseType, String area, Integer floor, String parkPlace, Date tenancy, String orientate, String region, String rentType, String houseState, Double rentMoney) {
        return houseMapper.selectHouseId(agentId,landlordId,houseEvaluate,landlordRequire,propertyOwnershipCertificate,houseType,area,floor,parkPlace,tenancy,orientate,region,rentType,houseState,rentMoney);
    }

    @Override
    public void updateByPrimaryKey(House house) {
houseMapper.updateByPrimaryKey(house);
    }

    @Override
    public void deleteByPrimaryKey(Integer id) {
houseMapper.deleteByPrimaryKey(id);
    }

    //分页
    @Override
    public PageInfo<House> findByPage( String type,String lab,Integer pageNow, Integer pageSize) {
        PageHelper.startPage(pageNow,pageSize);

        List<House> houses = searchAll(type,lab);

        PageInfo<House> housePageInfo = new PageInfo<>(houses);

        return housePageInfo;
    }

    //分页
    @Override
    public PageInfo<House> findByAllPage(String type,String lab,Integer min,Integer max ,Integer pageNow, Integer pageSize){
        PageHelper.startPage(pageNow,pageSize);

        List<House> houses = searchStudentAll(type,lab,min,max);

        PageInfo<House> housePageInfo = new PageInfo<>(houses);

        return housePageInfo;
    };

    //学生最终分页
    public PageInfo<House> finalPage(String lab,String min,String max ,String type,String chao,Integer pageNow, Integer pageSize){
        PageHelper.startPage(pageNow,pageSize);

        List<House> houses = finalSearch(lab, min,max,type,chao);

        PageInfo<House> housePageInfo = new PageInfo<>(houses);

        return housePageInfo;
    }

    @Override
    public List<House> findById(Integer integer) {
        return  houseMapper.findById(integer);
    }

    @Override
    public List<House> findByHouseType(String str) {
        return houseMapper.findByHouseType(str);
    }


    @Override
    public House selectById(Integer integer) {
       return houseMapper.selectById(integer);
    }

    @Override
    public List<House> studentAll() {
        return houseMapper.studentAll();
    }

    @Override
    public List<House> regionAll(String lab) {
        return houseMapper.regionAll("虎丘区");
    }

    @Override
    public List<House> searchAll(String str, String lab) {
        return houseMapper.searchAll(str,lab);
    }
    @Override
    public List<House> searchStudentAll(String str,String lab,Integer min,Integer max){
        return houseMapper.searchStudentAll(str,lab,min,max);
    }


    //最终搜索
    @Override
    public List<House> finalSearch(String lab, String min,String max,String type, String chao){
        return houseMapper.finalSearch(lab,min,max,type,chao);
    }




    //白领
    @Override
    public List<House> whiteFindByHouseType(String str) {
        return houseMapper.whiteFindByHouseType(str);
    }

    @Override
    public List<House> FindById(Integer integer, String rent_type) {
        return houseMapper.FindById(integer);
    }

    @Override
    public PageInfo<House> FindByIdPage(Integer integer, String rent_type, Integer pageNow, Integer pageSize) {
        PageHelper.startPage(pageNow,pageSize);

        List<House> houses =  FindById(integer,rent_type);

        PageInfo<House> housePageInfo = new PageInfo<>(houses);

        return housePageInfo;
    }

    @Override
    public House whiteSelectById(Integer integer) {
        return houseMapper.whiteSelectById(integer);
    }

    @Override
    public List<House> whiteAll() {
        return houseMapper.whiteAll();
    }

    @Override
    public List<House> whiteSearchAll(String str, String lab) {
        return houseMapper.whiteSearchAll(str,lab);
    }

    @Override
    public List<House> finalWhiteSearch( String lab,String min,String max, String type, String chao){
        return houseMapper.finalWhiteSearch(lab,min,max,type,chao);
    }

    //白领最终分页
    public PageInfo<House> finalWhitePage(String lab,String min,String max ,String type,String chao,Integer pageNow, Integer pageSize){
        PageHelper.startPage(pageNow,pageSize);

        List<House> houses = finalWhiteSearch(lab,min,max,type,chao);

        PageInfo<House> housePageInfo = new PageInfo<>(houses);

        return housePageInfo;
    }

    @Override
    public PageInfo<House> whiteTypePage(String type, String lab, Integer pageNow, Integer pageSize) {
        PageHelper.startPage(pageNow,pageSize);

        List<House> houses = whiteSearchAll(type,lab);

        PageInfo<House> housePageInfo = new PageInfo<>(houses);

        return housePageInfo;
    }

    //合租

    @Override
    public List<House> finalHeSearch( String lab,String min,String max, String type, String chao){
        return houseMapper.finalHeSearch(lab,min,max,type,chao);
    }

    //合租分页
    @Override
    public PageInfo<House> finalHePage(String lab,String min,String max ,String type,String chao,Integer pageNow, Integer pageSize){
        PageHelper.startPage(pageNow,pageSize);

        List<House> houses = finalHeSearch(lab,min,max,type,chao);

        PageInfo<House> housePageInfo = new PageInfo<>(houses);

        return housePageInfo;
    }


    //整租
    @Override
    public List<House> findZhengAll(){
        return houseMapper.findZhengAll();
    }


    @Override
    public PageInfo<House> finalZhengAllPage(Integer pageNow, Integer pageSize){
        PageHelper.startPage(pageNow,pageSize);

        List<House> houses = findZhengAll();

        PageInfo<House> housePageInfo = new PageInfo<>(houses);

        return housePageInfo;
    }


    public List<House> finalZhengSearch( String lab,String min,String max, String type, String chao){
        return houseMapper.finalZhengSearch(lab,min,max,type,chao);
    }
    //整租分页
    public PageInfo<House> finalZhengPage(String lab,String min,String max ,String type,String chao,Integer pageNow, Integer pageSize){
        PageHelper.startPage(pageNow,pageSize);

        List<House> houses = finalZhengSearch(lab,min,max,type,chao);

        PageInfo<House> housePageInfo = new PageInfo<>(houses);

        return housePageInfo;
    }



    //环境 - 类型 - 白领
    @Override
    public List<House> houseFacility(
            String green, String traffic,String shop, String school, String fridge,
            String tv,String wash,String geyser, String air,String broad,
            String sofa, String bed, String heat, String wardrobe, String cook,
            String bath, String balcony, String lock,String hood, String stove){
        return houseMapper.houseFacility(green, traffic,shop, school,fridge,
                tv,wash, geyser,  air, broad,
                sofa,  bed, heat, wardrobe, cook,
               bath, balcony, lock, hood,  stove);
    }

    @Override
    public PageInfo<House> houseFacilityPage(String green, String traffic,String shop, String school, String fridge,
                                   String tv,String wash,String geyser, String air,String broad,
                                   String sofa, String bed, String heat, String wardrobe, String cook,
                                   String bath, String balcony, String lock,String hood, String stove,
                                   Integer pageNow, Integer pageSize){
        PageHelper.startPage(pageNow,pageSize);
        List<House> houses = houseFacility(green, traffic,shop, school,fridge,
                tv,wash, geyser,  air, broad,
                sofa,  bed, heat, wardrobe, cook,
                bath, balcony, lock, hood,  stove);
        PageInfo<House> housePageInfo = new PageInfo<>(houses);
        return housePageInfo;

    }

    //环境 - 类型 - 学生
    @Override
    public List<House> houseStudentFacility(
            String green, String traffic,String shop, String school, String fridge,
            String tv,String wash,String geyser, String air,String broad,
            String sofa, String bed, String heat, String wardrobe, String cook,
            String bath, String balcony, String lock,String hood, String stove){
        return houseMapper.houseStudentFacility(green, traffic,shop, school,fridge,
                tv,wash, geyser,  air, broad,
                sofa,  bed, heat, wardrobe, cook,
                bath, balcony, lock, hood,  stove);
    }

    @Override
    public PageInfo<House> houseStudentFacilityPage(String green, String traffic,String shop, String school, String fridge,
                                             String tv,String wash,String geyser, String air,String broad,
                                             String sofa, String bed, String heat, String wardrobe, String cook,
                                             String bath, String balcony, String lock,String hood, String stove,
                                             Integer pageNow, Integer pageSize){
        PageHelper.startPage(pageNow,pageSize);
        List<House> houses = houseStudentFacility(green, traffic,shop, school,fridge,
                tv,wash, geyser,  air, broad,
                sofa,  bed, heat, wardrobe, cook,
                bath, balcony, lock, hood,  stove);
        PageInfo<House> housePageInfo = new PageInfo<>(houses);
        return housePageInfo;

    }


    //环境 - 类型 - 合租
    @Override
    public List<House> houseHeFacility(
            String green, String traffic,String shop, String school, String fridge,
            String tv,String wash,String geyser, String air,String broad,
            String sofa, String bed, String heat, String wardrobe, String cook,
            String bath, String balcony, String lock,String hood, String stove){
        return houseMapper.houseHeFacility(green, traffic,shop, school,fridge,
                tv,wash, geyser,  air, broad,
                sofa,  bed, heat, wardrobe, cook,
                bath, balcony, lock, hood,  stove);
    }

    @Override
    public PageInfo<House> houseHeFacilityPage(String green, String traffic,String shop, String school, String fridge,
                                             String tv,String wash,String geyser, String air,String broad,
                                             String sofa, String bed, String heat, String wardrobe, String cook,
                                             String bath, String balcony, String lock,String hood, String stove,
                                             Integer pageNow, Integer pageSize){
        PageHelper.startPage(pageNow,pageSize);
        List<House> houses = houseHeFacility(green, traffic,shop, school,fridge,
                tv,wash, geyser,  air, broad,
                sofa,  bed, heat, wardrobe, cook,
                bath, balcony, lock, hood,  stove);
        PageInfo<House> housePageInfo = new PageInfo<>(houses);
        return housePageInfo;

    }

    //环境 - 类型 - 整租
    @Override
    public List<House> houseZhengFacility(
            String green, String traffic,String shop, String school, String fridge,
            String tv,String wash,String geyser, String air,String broad,
            String sofa, String bed, String heat, String wardrobe, String cook,
            String bath, String balcony, String lock,String hood, String stove){
        return houseMapper.houseZhengFacility(green, traffic,shop, school,fridge,
                tv,wash, geyser,  air, broad,
                sofa,  bed, heat, wardrobe, cook,
                bath, balcony, lock, hood,  stove);
    }

    @Override
    public PageInfo<House> houseZhengFacilityPage(String green, String traffic,String shop, String school, String fridge,
                                             String tv,String wash,String geyser, String air,String broad,
                                             String sofa, String bed, String heat, String wardrobe, String cook,
                                             String bath, String balcony, String lock,String hood, String stove,
                                             Integer pageNow, Integer pageSize){
        PageHelper.startPage(pageNow,pageSize);
        List<House> houses = houseZhengFacility(green, traffic,shop, school,fridge,
                tv,wash, geyser,  air, broad,
                sofa,  bed, heat, wardrobe, cook,
                bath, balcony, lock, hood,  stove);
        PageInfo<House> housePageInfo = new PageInfo<>(houses);
        return housePageInfo;

    }


    @Override
    public int insertHouse(House house) {
        return houseMapper.insertHouse(house);
    }

    @Override
    public House selectByhouseId(Integer houseId) {
        return houseMapper.selectByhouseId(houseId);
    }

    @Override
    public List<House> selectBylandlordId(Integer landlordId) {
        return houseMapper.selectBylandlordId(landlordId);
    }

    @Override
    public int deleteById(Integer id) {
        return houseMapper.deleteById(id);
    }

    @Override

    public Integer selectagentByhouseId(Integer integer) {
        return houseMapper.selectagentByhouseId(integer);
    }
        @Override
    public List<House> selectByagentId(Integer agentId) {
        return houseMapper.selectByagentId(agentId);
    }


}
